<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!doctype html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta name="apple-mobile-web-app-status-bar-style" content="black" />
	<meta name="format-detection" content="telephone=no" />
	<meta name="version" content="">
	<meta http-equiv="Cache-Control" content="must-revalidate,no-cache">
	<meta http-equiv="x-dns-prefetch-control" content="on" />
	<title>资讯详情</title>
	<link type="text/css" rel="stylesheet" href="${ctx}/static/h5/css/zixun.css" />
	<link rel="stylesheet" href="${ctx}/static/h5/css/toast.css">

</head>
<%--<script>--%>
	<%--Zepto(function($){--%>
		<%--if("${download.is_app}" != "true"){--%>
			<%--fixed_footer({--%>
				<%--logoUrl:"${download.logoUrl}",//logo图片url--%>
				<%--title:"${download.title}",//标题--%>
				<%--text:"${download.text}",//简介--%>
				<%--btnTxt:"${download.btnTxt}",//按钮文字--%>
				<%--url:"${download.downloadUrl}",//按钮点击跳转url--%>
			<%--});--%>
		<%--}--%>
	<%--})--%>
<%--</script>--%>
<body>
<header>
	<img src="${object.detailpic}" class="banner" />
	<div class="evaluate">
		<h3>${object.title}</h3>
		<div class="tag clr">
			<c:if test="${!empty object.source_string }">
				<div class="left">
					<span>来源:</span>${object.source_string}
				</div>
			</c:if>

			<div class="right">
				<span><fmt:formatDate value="${object.deployTime}" pattern="yyyy-MM-dd"/></span>
			</div>
		</div>

	</div>
</header>
<section>
	<div class="line"></div>
	<div class="content" >
		<p>${object.content}</p>
	</div>
</section>
<footer class="footer">

	<p><span class="icon eye">${object.scanNum}</span>
		<%--<span class="icon 	<c:choose>
		<c:when test="${good}">
			hand-active
		</c:when>
		<c:otherwise>
			hand
		</c:otherwise>
	</c:choose>" id="good">${object.praise_count}</span>--%></p>
</footer>
<%--<section class="evalue-list" id="evalue-list">
	<p class="t-line"></p>
	<h3 class="nice-text">精彩评论</h3>
	<!-- 评论列表  start-->

	<!-- 评论列表  end-->
</section>--%>
<%--<jsp:include page="${ctx}/theme/h5/jsp/residentDownload.jsp"/>--%>
<script type="text/javascript" src="${ctx}/static/h5/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="${ctx}/static/h5/js/initRem.js"></script>
<script type="text/javascript" src="${ctx}/static/h5/js/toast.js"></script>
<%--<script src="${ctx}/theme/h5/js/zepto.min.js"></script>--%>
<%--<script src="${ctx}/theme/h5/js/common.js"></script>--%>
<%--<script src="${ctx}/theme/h5/js/fixed_footer.js"></script>--%>
<script type="text/javascript">
	var start = 0;
	var length = 20;
	$(function(){
		//点赞
		$("#good").click(function(){
			var $this = $(this);
			if($(this).hasClass('hand-active')){
				return false;
			}else{
				$.ajax({
					url: '${ctx}/h5/news/praise',
					type: 'post',
					data: {"uid":"${uid}","newsId":"${newsId}"},
					dataType:"json",
					success:function(result){
						if(result.status == 1) {
							$this.removeClass('hand').addClass('hand-active');
							var sum = parseInt($this.html());
							$this.html(sum+1);
						} else if(result.status == -1){
							$.toast_self({text:result.msg,timeout:'3000'});
						} else {
							location.href = "aijk://resident/health/login";
						}
					},
					error:function(){

					}
				});
			}
		});
		loadCommentData(start,length,true);
	});

	//滚动条在Y轴上的滚动距离
	function getScrollTop(){
		var scrollTop = 0, bodyScrollTop = 0, documentScrollTop = 0;
		if(document.body){
			bodyScrollTop = document.body.scrollTop;
		}
		if(document.documentElement){
			documentScrollTop = document.documentElement.scrollTop;
		}
		scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop;
		return scrollTop;
	}

	//文档的总高度
	function getScrollHeight(){
		var scrollHeight = 0, bodyScrollHeight = 0, documentScrollHeight = 0;
		if(document.body){
			bodyScrollHeight = document.body.scrollHeight;
		}
		if(document.documentElement){
			documentScrollHeight = document.documentElement.scrollHeight;
		}
		scrollHeight = (bodyScrollHeight - documentScrollHeight > 0) ? bodyScrollHeight : documentScrollHeight;
		return scrollHeight;
	}

	//浏览器视口的高度
	function getWindowHeight(){
		var windowHeight = 0;
		if(document.compatMode == "CSS1Compat"){
			windowHeight = document.documentElement.clientHeight;
		}else{
			windowHeight = document.body.clientHeight;
		}
		return windowHeight;
	}

	function loadCommentData(start ,length,isFirst) {
		$.ajax({
			url: '${ctx}/h5/news/comment',
			type: 'post',
			data: {"start":start,"length":length,"nid":"${newsId}"},
			dataType:"json",
			success:function(result){
				if(isFirst && result.recordsTotal == 0) {
					var emptyHtml='<p class="empty">暂无评论</p>';
					$("#evalue-list").append(emptyHtml);
				}
				var rates = result.data;
				if(rates != null && rates.length > 0) {
					for(var i = 0;i < rates.length;i++) {
						var listHtml='<section class="list">';
						if(rates[i].avatar != null && rates[i].avatar != '') {
							listHtml+='<article class="img"><img src=' + rates[i].avatar + ' alt=""></article>';
						} else {
							listHtml+='<article class="img"><img src="${ctx}/theme/h5/images/default_ico.png" alt=""></article>';
						}
						listHtml+='<article class="text">';
						listHtml+='<p class="name">'+ rates[i].name + '</p>';
						listHtml+='<p class="msg">' + rates[i].content + '</p>';
						listHtml += '<p class="time">' + rates[i].created + '</p></article></section>';
						$("#evalue-list").append(listHtml);
					}
				}
			},
			error:function(){

			}
		});
	}

	window.onscroll = function(){
		if(getScrollTop() + getWindowHeight() == getScrollHeight()){
			start = start + length;
			loadCommentData(start,length,false);
		}
	};
	if("${download.is_app}" != "true"){//如果是微信分享出去的页面，把点赞功能隐藏掉
		$(".footer").css("display","none");
	}
</script>
</body>
</html>
